#!/bin/bash

RSYNC_SERVER=192.168.20.160
RSYNC_MOUDLE=backup
MY_PATH=/backup
MY_IP=`ifconfig eth1 |awk -F '[ :]+' 'NR==2 { print $4 }'`
MY_DIR="${MY_IP}_$(date +%F)"
NGX_CONF_DIR=/application/nginx/conf

mkdir -p ${MY_PATH}/${MY_DIR} 

/bin/cp /var/spool/cron/root ${MY_PATH}/${MY_DIR}/cron_root_$(date +%F)
/bin/cp /etc/rc.local ${MY_PATH}/${MY_DIR}/rc.local_$(date +%F) 
/bin/cp /etc/hosts ${MY_PATH}/${MY_DIR}/hosts_$(date +%F) 
/bin/cp /etc/security/limits.conf ${MY_PATH}/${MY_DIR}/limits_$(date +%F) 
/bin/cp ${NGX_CONF_DIR}/nginx.conf ${MY_PATH}/${MY_DIR}/nginx.conf_$(date +%F)
/bin/cp -r ${NGX_CONF_DIR}/extra/ ${MY_PATH}/${MY_DIR}/nginx_extra_$(date +%F)

rsync -az ${MY_PATH}/ rsync_backup@${RSYNC_SERVER}::${RSYNC_MOUDLE}/ --password-file=/etc/rsync.password
